import React, {Component} from 'react';
import {PrivateRouter} from '../../privateRouter'
/*import AddUser from "../../views/user/AddUser";
import UserList from "../../views/user/UserList";*/

//自动化
const files = require.context("../../views",true,/\.js$/);
const components = [];
files.keys().forEach(e=>{
    if( e.includes('./index/') || e.includes("./login/"))return false;
    //分割字符串
    const splitFilesName = e.split(".")
    const jsonObj = {};
    //  path
    const path = `/index${splitFilesName[1].toLowerCase()}`;
    //component
    const component = files(e).default;
    //写入对象
    jsonObj.component = component;
    jsonObj.path = path;
    components.push(jsonObj);
})
console.log(components)
export default class ContainerMain extends Component {
    constructor(props) {
        super(props);
        this.state = {};
    }

    render() {
        return (
            <>
                {
                    components.map(e=>{
                        console.log(e.path)
                        return (
                            <PrivateRouter  key={e.path} exact component={e.component} path={e.path} />
                        )
                    })
                }
                {/*<PrivateRouter exact component={AddUser} path={'/index'} />*/}
                {/*<PrivateRouter exact component={UserList} path={'/index/user/list'} />*/}
            </>
        )
    }
}
